d= {
    "name":"sunyanzi",
    "age":23,
    "gender":"女",
    "height":170
}
print(d)
#新增键对值

d['weight']=100
print(d)

#获取键对值
print(d['name'])

#修改键对值

d['height']=165

print(d)

#删除字典

#del d

#判断键对是否存在于字典
print('age'in d)

#字典的遍历
for i in d :
    print(i,d[i])

for key,value in d.items():
    print(key,value)

print(d.items())

for k in d.keys():
    print(k)

for v in d.values():
    print(v)
#字典的常用方法
#删除
d.pop('name')
print(d)

#清除
#d.clear()
#print(d)


a=d.copy()
print("a的键对值：",a)

#获取值
print(d.get('gender'))


#从字典后抛出键对值，每次运行抛出一个
d.popitem()
print('pop',d)


d.update({'age':18})
print('update',d)



